home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / SUPERPD.PAK / PADDOC.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  3KB  |  105 lines

  1. // paddoc.cpp : implementation of the CPadDoc class
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13.  
  14. #include "stdafx.h"
  15. #include "superpad.h"
  16. #include "paddoc.h"
  17. #include "paditem.h"
  18. #include "linkitem.h"
  19.  
  20. #ifdef _DEBUG
  21. #undef THIS_FILE
  22. static char BASED_CODE THIS_FILE[] = __FILE__;
  23. #endif
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CPadDoc
  27.  
  28. IMPLEMENT_DYNCREATE(CPadDoc, COleServerDoc)
  29.  
  30. BEGIN_MESSAGE_MAP(CPadDoc, COleServerDoc)
  31.     //{{AFX_MSG_MAP(CPadDoc)
  32.     ON_COMMAND(ID_VIEW_UPDATENOW, OnViewUpdatenow)
  33.     ON_COMMAND(ID_CANCEL_INPLACE, OnCancelInplace)
  34.     //}}AFX_MSG_MAP
  35. END_MESSAGE_MAP()
  36.  
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CPadDoc delegation to CEditView
  39.  
  40. CPadDoc::CPadDoc()
  41. {
  42. }
  43.  
  44. CPadDoc::~CPadDoc()
  45. {
  46. }
  47.  
  48. void CPadDoc::DeleteContents()
  49. {
  50.     COleServerDoc::DeleteContents();
  51.     if (m_viewList.IsEmpty())
  52.         return;
  53.     CEditView* pView = (CEditView*)m_viewList.GetHead();
  54.     ASSERT_KINDOF(CEditView, pView);
  55.     pView->DeleteContents();
  56. }
  57.  
  58. void CPadDoc::Serialize(CArchive& ar)
  59. {
  60.     CEditView* pView = (CEditView*)m_viewList.GetHead();
  61.     ASSERT_KINDOF(CEditView, pView);
  62.     pView->SerializeRaw(ar);
  63. }
  64.  
  65. COleServerItem* CPadDoc::OnGetEmbeddedItem()
  66. {
  67.     CEmbeddedItem* pItem = new CEmbeddedItem(this);
  68.     ASSERT_VALID(pItem);
  69.     return pItem;
  70. }
  71.  
  72. COleServerItem* CPadDoc::OnGetLinkedItem(LPCTSTR lpszItemName)
  73. {
  74.     CPadLinkItem *pItem =
  75.         (CPadLinkItem*)COleServerDoc::OnGetLinkedItem(lpszItemName);
  76.     if (pItem == NULL)
  77.         pItem = new CPadLinkItem(this, lpszItemName);
  78.  
  79.     ASSERT_VALID(pItem);
  80.     return pItem;
  81. }
  82.  
  83. /////////////////////////////////////////////////////////////////////////////
  84.  
  85. void CPadDoc::OnViewUpdatenow()
  86. {
  87.     UpdateAllItems(NULL);
  88. }
  89.  
  90. // Note: both the server and the container should have a keyboard method
  91. //  of deactivating an active in-place item.
  92.  
  93. void CPadDoc::OnCancelInplace()
  94. {
  95.     if (IsInPlaceActive())
  96.         OnDeactivateUI(FALSE);
  97. }
  98.  
  99. void CPadDoc::SetSelection(int nBeg, int nEnd)
  100. {
  101.     CEditView* pView = (CEditView*)m_viewList.GetHead();
  102.     ASSERT_KINDOF(CEditView, pView);
  103.     pView->GetEditCtrl().SetSel(nBeg, nEnd);
  104. }
  105.